import * as uuid from "uuid";
import { Button } from "antd";
import { useState, useEffect } from "react";

export default () => {
    const [version, setVersion] = useState("v4");
    const [uuidString, setUUIDString] = useState("");

    useEffect(() => {
        genUUID();
    }, []);

    const genUUID = () => {
        let id = uuid[version]();
        setUUIDString(id);
    };

    const onChange = (e) => {
        setVersion(e.target.value);
    };

    return (
        <div>
            {/* <Space>
                <Radio.Group onChange={onChange} value={version}>
                    <Radio value={"v1"}>V1</Radio>
                    <Radio value={"v3"}>V3</Radio>
                    <Radio value={"v4"}>V4</Radio>
                    <Radio value={"v5"}>V5</Radio>
                </Radio.Group>
            </Space> */}
            <div style={{ marginTop: 10 }}>
                <Button type="primary" onClick={genUUID}>
                    生成UUID
                </Button>
            </div>
            <div style={{ marginTop: 10 }}>UUID： {uuidString}</div>
        </div>
    );
};
